import {Component, Input, OnInit} from '@angular/core';
import {AdminService} from "../../../../services/admin.service";
import {AlertService} from "../../../../services/alert.service";
import {BlockchainService} from "../../../../services/blockchain.service";
import {HistoryBlockChain} from "../../../../vo/HistoryBlockChain";
import {ActivatedRoute} from "@angular/router";

@Component({
  selector: 'app-symessagelist',
  templateUrl: './symessagelist.component.html',
  styleUrls: ['./symessagelist.component.css']
})
export class SymessagelistComponent implements OnInit {
str="";
  hls:Array<HistoryBlockChain>

  constructor(private adminService:AdminService,
              private alertService:AlertService,
              private blockchainSrvice:BlockchainService,
              private parm:ActivatedRoute) {
  this.hls = new Array()

  }

  ngOnInit(): void {
  // this.parm.snapshot.queryParamMap.get("str").
  //   then((value:any)=>{
  //   this.str = value
  // })
  this.str=this.parm.snapshot.paramMap.get("str")!




  this.getHistoryByKeyForHistory()
  }
  getHistoryByKeyForHistory(){
    console.dir(this.str)

    this.blockchainSrvice.getHistoryByKeyForHistory(this.str).then((data:any)=>{
      if(data.msg == "ok"){
  this.hls = data.list
      }else{
        console.dir(data.msg)
        this.alertService.showError("获取溯源信息失败")
      }
    })
  }
}
